package com.cn.zsc.service;

import com.cn.zsc.dblocal.dao.OrderMapper;
import com.cn.zsc.dblocal.model.Order;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

@Service
public class OrderService {

    @Resource
    private OrderMapper orderMapper;

    /**
     * 订单回调接口
     * @param orderId
     * @return 1订单不存在 0 回调成功
     */
    public int handleOrder(int orderId){
        Order order = orderMapper.selectByPrimaryKey(orderId);
        if (order == null) return 1;
        order.setOrderStatus(1); // 已支付
        order.setUpdateTime(new Date());
        order.setUpdateUser(0);
        orderMapper.updateByPrimaryKey(order);
        return 0;
    }
}
